package com.ugoodtech.mdcc.core.utils;

import java.lang.reflect.Field;

public class CheckObjects {

    public static boolean objCheckIsNull(Object object) {
        // 得到类对象
        Class clazz = (Class) object.getClass();
        // 得到所有属性
        Field fields[] = clazz.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            Object fieldValue = null;
            try {
                //得到属性值
                fieldValue = field.get(object);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            if (fieldValue != null && !fieldValue.toString().equals("")) {
                //只要有一个属性值不为null 就返回true
                return true;
            }
        }
        return false;
    }

}
